import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入Element Plus中文语言包
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import router from './router'
import App from './App.vue'
// 初始化应用配置
import '@/config/app'
import { useAuthStore } from '@/stores/auth.js'

const app = createApp(App)
const pinia = createPinia()

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(pinia)
app.use(router)
// 使用中文语言包配置Element Plus
app.use(ElementPlus, {
  locale: zhCn,
})

// 初始化认证状态
const authStore = useAuthStore()
authStore.initAuth()

app.mount('#app')
